package cn.GetPath;

import java.io.File;

public class accessPath {



    /*获取后缀名为txt的文件路径*/
    public static String getTxt() {
        File tmpFile = new File(new File("C://Users//Administrator//Desktop//Import").getAbsolutePath());

        File[] files = tmpFile.listFiles();

        for (File file : files) {
            String name = file.getName();
            if (name.matches("^.+\\.(txt)$"))
                return "C://Users//Administrator//Desktop//Import//" + name;
        }
        return null;
    }

    /*获取后缀名为xls的文件路径*/
    public static String getXls() {
        File tmpFile = new File(new File("C://Users//Administrator//Desktop//Import").getAbsolutePath());

        File[] files = tmpFile.listFiles();
        for (File file : files) {
            String name = file.getName();
            if (name.matches("^.+\\.(xls)$"))
                return "C://Users//Administrator//Desktop//Import//" + name;
        }
        return null;

    }

    public static String getXlsx() {
        File tmpFile = new File(new File("C://Users//Administrator//Desktop//Import//test").getAbsolutePath());

        File[] files = tmpFile.listFiles();
        for (File file : files) {
            String name = file.getName();
            if (name.matches("^.+\\.(xls)$"))
                return "C://Users//Administrator//Desktop//Import//test//" + name;
        }
        return null;

    }


}
